package vn.wallet.app.domain;

// Generated Nov 15, 2012 12:09:27 PM by Hibernate Tools 3.4.0.CR1

import static javax.persistence.GenerationType.IDENTITY;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 * Category generated by hbm2java
 */
@Entity
@Table(name = "category", catalog = "wallet")
public class Category implements java.io.Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private int id;
	private User user;
	private String name;
	private String description;
	private boolean status = true;
	private Date createDate;
	private Date lastModified;
	private Set<Record> records = new HashSet<Record>(0);
	private int parentId;

	public Category() {
	}

	public Category(User user) {
		this.user = user;
	}

	public Category(int parentId, User user, String name, boolean status, Date createDate) {
		this.parentId = parentId;
		this.user = user;
		this.name = name;
		this.status = status;
		this.createDate = createDate;
	}

	public Category(int parentId, User user, String name, String description, boolean status,
			Date createDate, Date lastModified, Set<Record> records) {
		this.parentId = parentId;
		this.user = user;
		this.name = name;
		this.description = description;
		this.status = status;
		this.createDate = createDate;
		this.lastModified = lastModified;
		this.records = records;
	}

	public Category(User user, String name, String description, Boolean status,
			Date createDate, Date lastModified, Set<Record> records) {
		super();
		this.user = user;
		this.name = name;
		this.description = description;
		this.status = status;
		this.createDate = createDate;
		this.lastModified = lastModified;
		this.records = records;
	}

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	public int getId() {
		return this.id;
	}

	public void setId(int id) {
		this.id = id;
	}

	@Column(name = "parent_id", nullable = false)
	public int getParentId() {
		return parentId;
	}

	public void setParentId(int parentId) {
		this.parentId = parentId;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "user_id", nullable = false)
	public User getUser() {
		return this.user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	@Column(name = "name", nullable = false)
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "description")
	public String getDescription() {
		return this.description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	@Column(name = "status", nullable = false)
	public boolean isStatus() {
		return this.status;
	}

	public void setStatus(boolean status) {
		this.status = status;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "created_on", nullable = false, length = 19, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP")
	public Date getCreateDate() {
		return this.createDate;
	}

	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}

	// @PrePersist
	// protected void onCreate() {
	// createDate = new Date();
	// }

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "last_modified", length = 19)
	public Date getLastModified() {
		return this.lastModified;
	}

	public void setLastModified(Date lastModified) {
		this.lastModified = lastModified;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "category")
	public Set<Record> getRecords() {
		return this.records;
	}

	public void setRecords(Set<Record> records) {
		this.records = records;
	}

	@Override
	public String toString() {
		return getName();
	}

}
